home *** CD-ROM | disk | FTP | other *** search
- /*
-
- Convert old Cache Filenames to the new format of Cache Filenames...
-
- - Directory OPus must be running in the background for this routine to work !!
-
- */
-
- /* trace ?R */
-
- say "Twin Opus Cache Filename Converter."
-
- if ~exists("TwinDirs:") then do
- say "you must have **TwinDirs:** assigned before you call this program"
- exit
- end
-
- if exists("TwinDirs:Redo_Complete") then do
- say "Conversion already done on this Dir !!"
- exit
- end
-
- /* list the files present into a file
- - last line of the file t:CDirs, contains verboce info */
- say "Reading in Dir of Cached Dirs..."
- address command "list quick files TwinDirs: >t:CDirs"
-
- /* convert the filenames */
- say "Now Converting the Filenames..."
- say " This could take a while if you have many Cached Dirs..."
-
- open(Files, "t:CDirs", Read)
-
- Cont = True
- Count = 0
- do while Cont = True
- OldName = readln(files)
- if left(OldName,1) > 9 then do
- Count = Count + 1
- address command "echo . noline"
-
- NewName = 'twindirs:' || ConvertFilename(OldName)
- FOldName = 'twindirs:' || OldName
- if FOldName ~= NewName then do
- /* not work !!addrexx command "rename " FOldName NewName */
-
- /* method:= read file, create the new file, and copy the data across */
- open(Input, FOldName, read )
- open(Output, NewName , write)
- do until EOF(Input)
- line = readln(Input)
- writeln(Output, line)
- end
- close(Input)
- close(Output)
- address command "delete " Quote(FOldName) " >NIL:"
- end
- end
- else
- Cont = False
- end
-
- /* write a file saying that these dirs have already been processed */
- open(temp, "TwinDirs:Redo_Complete", Write)
- writeln(temp, "Dirs already Processed !!")
- close(temp)
-
- /* all done */
- say " "
- say " "
- say "All Done... I processed " Count " conversions !!"
-
- exit
-
- /*---------------------------------------------------------------------------*/
-
- /* convert a file name from 'df0=ray\was\here to -> `d0=ry\ws\he
- (old name) (new cache filename)*/
- ConvertFilename: procedure
-
- parse arg Dev '=' Path
-
- t2 = ''
- Convert = ''
- do until (t2 = '')
- parse var Path t1 '\' t2
- Path = t2
- if t2 ~= '' then
- end = '\'
- else
- end = ''
- Convert = Convert || left(t1,1) || right(t1,1) || end
- end
-
- if left(Convert,1) = ' ' then
- Convert = ''
-
- out = Dev || '=' || Convert
-
- return out
-
- /*--------------------------------------------------------------------------*/
-
- Quote: procedure /* add quotes to string */
-
- parse arg string
-
- return '"'||string||'"'
-